<?php 
/****************************************/
/************* IdeaLAN LLC **************/
/* Upload module it will upload images, */
/* files and documents, to a specified  */
/* location.                            */
/*                                      */
/****************************************/
/****************************************/
/* SCRIPT: upload.php                   */
/* AUTHOR: Lukasz Piekarski             */
/* E-mail: lukasz@idealan.net           */
if (file_exists("upload.php")) {	$mod_lud = filemtime("upload.php"); }		
$mod_ver	=	"1.0";
/****************************************/
/*
TODO UPLOAD	+
			- add the abilty to upload files in to specific locations. 
END TODO UPLOAD
*/

/* ------------ UPLOAD HTML EXAMPLE

<form action=\"scripts/ajaxupload.php\" method=\"post\" name=\"standard_use\" id=\"standard_use\" enctype=\"multipart/form-data\">
<input type=\"file\" name=\"file\" />
<button onclick=\"ajaxUpload(this.form,'scripts/upload.php?upload=image&fL=UPLOADLOCATION','upload_area','File Uploading Please Wait...&lt;br /&gt;&lt;img src=\'../g/loader_light_blue.gif\' /&gt;','&lt;img src=\'../g/error.gif\' /&gt; Error in Upload, check settings and path info in source code.'); this.disabled=true; return false;\">Upload Image</button>
</form>
				
<div id=\"upload_area\">"; 
</div>
					
------------  END UPLOAD HTML EXAMPLE */


// LETS GET GLOBAL VARIABLES
$fileLocation = $_GET["fL"];

if (!$_GET[upload]) {
	echo "<img src='../g/error.gif' style='marin-bottom: -3px;' /> There has been an ERORR! #1 ";
}

if ($_GET[upload] == "image") {

$filename		= $_FILES['file']['name'];
$filesize		= $_FILES['file']['size'];
$filename_temp 	= $_FILES['file']['tmp_name']; 
$filetype		= substr($filename,-4);


//UPLOAD EXTENSIONS

if ($filetype == ".png") {

	if (file_exists("../storage/logo.png")) { unlink("../storage/logo.png"); }

		$upload_OK = move_uploaded_file($filename_temp, $fileLocation . "logo.png"); 

		if($upload_OK){
			echo "<img src='../g/success.gif' style='marin-bottom: -4px;' /> Success!<br /><img src='../members/storage/logo.png' />";
		} else {
			echo "<img src='../g/error.gif' style='marin-bottom: -3px;' /> There has been an ERORR! #2 ";
		}
} else {

	echo "<img src='../g/error.gif' style='marin-bottom: -3px;' /> File is not allowed. ";
	
}

}
  
?>